﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Joyintech.Model.inpiao365;

namespace Joyintech.BLL.inpiao365
{
    public partial class screenings_BLL
    {
        /// <summary>
        /// 获取影院电影场次信息
        /// </summary>
        /// <param name="movieid">电影ID</param>
        /// <param name="cinemaid">影院ID</param>
        /// <param name="currentdate">放映时间，以某日为单位</param>
        /// <returns></returns>
        public List<screeningsExtend> GetList(string movieid, string cinemaid, DateTime currentdate)
        {
            DataSet ds = dal.GetList(movieid, cinemaid, currentdate);
            return DataTableToListCustom(ds.Tables[0]);
         
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<screeningsExtend> DataTableToListCustom(DataTable dt)
        {
            List<screeningsExtend> modelList = new List<screeningsExtend>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                screeningsExtend model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new screeningsExtend();
                    if (dt.Columns.Contains("ScreeningsId"))
                    {
                        if (dt.Rows[n]["ScreeningsId"].ToString() != "")
                        {
                            model.ScreeningsId = Convert.ToInt32(dt.Rows[n]["ScreeningsId"].ToString());
                        }
                    }
                    if (dt.Rows[n]["MovieSeatTime"].ToString() != "")
                    {
                        model.MovieSeatTime = Convert.ToDateTime(dt.Rows[n]["MovieSeatTime"].ToString());
                    }
                    if (dt.Columns.Contains("MovieId"))
                    {
                        if (dt.Rows[n]["MovieId"].ToString() != "")
                        {
                            model.MovieId = Convert.ToInt32(dt.Rows[n]["MovieId"].ToString());
                        }
                    }
                    model.MovieName = dt.Rows[n]["MovieName"].ToString();
                    if (dt.Columns.Contains("TheaterRoomId"))
                    {
                        if (dt.Rows[n]["TheaterRoomId"].ToString() != "")
                        {
                            model.TheaterRoomId = Convert.ToInt32(dt.Rows[n]["TheaterRoomId"].ToString());
                        }
                    }
                    model.TheaterRoomName = dt.Rows[n]["TheaterRoomName"].ToString();
                    model.MovieType = dt.Rows[n]["MovieType"].ToString();
                   
                    if (dt.Columns.Contains("Price"))
                    {
                        if (dt.Rows[n]["Price"].ToString() != "")
                        {
                            model.Price = decimal.Parse(dt.Rows[n]["Price"].ToString());
                        }
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }


        public ThreaterExtend GetThreaterExtendModel(int theaterid)
        {
            theater_BLL theardal = new theater_BLL();

            theater temp = theardal.GetModel(theaterid);
            ThreaterExtend model = new ThreaterExtend();
            if (temp == null)
            {

            }
            else
            {
                systemArea_BLL areadal = new systemArea_BLL();
                systemArea area = areadal.GetModelByCache(temp.AreaId);
                model.AreaName = area.Name;
                model.Address = temp.TheaterAddress;
                model.TheaterName = temp.TheaterName;
            }
            return model;
        }


        /// <summary>
        /// 获得影院的热映电影
        /// </summary>
        /// <param name="theaterid"></param>
        /// <returns></returns>
        public DataSet GetHotMovie(string theaterid)
        {
            return dal.GetHotMovie(theaterid);
           
        }
    }


    /// <summary>
    /// 电影场次扩展类
    /// </summary>
    public class screeningsExtend:Joyintech.Model.inpiao365.screenings
    {
        private String movieType;

        public String MovieType
        {
            get { return movieType; }
            set { movieType = value; }
        }
        private String theaterRoomName;

        public String TheaterRoomName
        {
            get { return theaterRoomName; }
            set { theaterRoomName = value; }
        }

       
    }


    public class ThreaterExtend
    {
        private String areaName;

        /// <summary>
        /// 影院所在地区名称
        /// </summary>
        public String AreaName
        {
            get { return areaName; }
            set { areaName = value; }
        }
        private String theaterName;

        /// <summary>
        /// 影院名称
        /// </summary>
        public String TheaterName
        {
            get { return theaterName; }
            set { theaterName = value; }
        }
        private String address;

        /// <summary>
        /// 影院地址
        /// </summary>
        public String Address
        {
            get { return address; }
            set { address = value; }
        }
    }
}
